package com.halden.TRPG.service;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.halden.TRPG.common.CodeEnum;
import com.halden.TRPG.common.MyException;
import com.halden.TRPG.entity.MessageEntity;
import com.halden.TRPG.entity.vo.MessageSendVo;

import javax.json.JsonObject;
import java.util.List;

public interface MessageService extends IService<MessageEntity> {

    // 存储消息
    public CodeEnum saveMessage(JSONObject jsonObject);

    // 缓存消息到redis
    boolean cacheMessageToRedis(MessageEntity entity);

    // 将同一个房间的消息存到数据库
    boolean saveMessagesToDB(List<MessageEntity> entities);

    // 最后一个成员退出房间时存储消息到数据库
    void saveMessageWhenClose(Long rid);

    public CodeEnum getMessage(String uid, Long rid, Long start, Long length);

    public CodeEnum createMessageTable(Long rid) throws MyException;

    public boolean deleteMessages(Long rid);

    CodeEnum downloadMessages(Long rid);

    CodeEnum saveDarkDice(JSONObject jsonObject);

    CodeEnum getDarkDiceMessage(Long rid);
}
